<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="ThemeBucket">
    <link rel="shortcut icon" href="#" type="image/png">

    <title>Form Layouts</title>
    <link href="/public/js/summernote/dist/summernote.css" rel="stylesheet">
    <!--multi-select-->
    <link rel="stylesheet" type="text/css" href="/public/js/jquery-multi-select/css/multi-select.css" />
    <!--tags input-->
    <link rel="stylesheet" type="text/css" href="/public/js/jquery-tags-input/jquery.tagsinput.css" />
    <script language="javascript">
        function RunOnBeforeUnload() {window.onbeforeunload = function(){ return ""; } }
    </script>
    <?php $this->load->view('library/header');?>
</head>

<body onload="" class="sticky-header">

<?php $this->load->view('library/left');?>

<!-- main content start-->
<div class="main-content" >

    <?php $this->load->view('library/top');?>

    <!-- page heading start-->
    <div class="page-heading">
        <h3>
            添加/修改部门
        </h3>
        <ul class="breadcrumb">
            <li>
                <a href="#">Forms</a>
            </li>
            <li class="active"> Forms Layouts </li>
        </ul>
    </div>
    <!-- page heading end-->

    <!--body wrapper start-->
    <section class="wrapper">
        <div class="row">
            <div class="col-md-12">
                <!-- page start-->
                <section class="panel">
                    <header class="panel-heading custom-tab turquoise-tab">
                        <ul class="nav nav-tabs">
                            <li class="active">
                                <a href="#home2" data-toggle="tab">添加/修改部门</a>
                            </li>
                        </ul>
                    </header>
                    <?php

                    ?>
                    <form id="commentForm" class="form-horizontal adminex-form" method="post">
                        <div class="panel-body">
                            <div class="tab-content">
                                <div class="tab-pane active" id="home2">
                                    <div class="form-group ">
                                        <label for="cname" class="control-label col-lg-2">部门名称</label>
                                        <div class="col-lg-10">
                                            <input class=" form-control" value="<?=$info['department_name']?>" name="department_name" type="text" />
                                        </div>
                                    </div>

                                    <div class="form-group ">
                                        <label for="cname" class="control-label col-lg-2">描述</label>
                                        <div class="col-lg-10">
                                            <textarea name="desc" id="" cols="100" rows="10" ><?=$info['desc']?></textarea >
                                        </div>
                                    </div>

                                    <div class="form-group ">
                                        <label for="cname" class="control-label col-lg-2">启用</label>
                                        <div class="col-lg-10">
                                            <?php  echo j_input_radio('status', [1 => '是', 2 => '否' ], $info['status']?:1 ); ?>
                                        </div>
                                    </div>
                                    <div class="form-group ">
                                        <label for="curl" class="control-label col-lg-2">选择父级</label>
                                        <div class="col-lg-2">
                                            <select name="pid" class="form-control">
                                                <option value="0">一级部门</option>
                                                <?php foreach($cate as $k => $v){?>
                                                    <option <?= $v['id']==$info['pid'] ?"selected":''?> value="<?php echo $v['id']?>"><?=str_repeat('&nbsp;',$v['level']).$v['department_name']?></option>
                                                <?php }?>
                                            </select>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <footer class="panel-footer">
                            <button type="button" onclick="add()" name="handle_type" value="0" class="btn btn-post pull-right btn-big">提交信息</button>
                            <ul class="nav nav-pills p-option"></ul>
                        </footer>
                        <input type="hidden" name="id" value="<?=$_GET['id']?>">
                    </form>
                </section>
                <!-- page end-->
            </div>
        </div>
    </section>
    <!--body wrapper end-->

    <!--footer section start-->
    <footer>
        2014 &copy; AdminEx by
    </footer>
    <!--footer section end-->


</div>
<!-- main content end-->
</section>
<?php $this->load->view('library/footer');?>
<script src="/public/js/scripts.js"></script>

</body>
<script >

  // window.onbeforeunload=function(){}
    function add() {
        var el = $("#commentForm");
        $.post("department_add",el.serialize(),function (data) {
            if (data.code !==200){
                layer.msg(data.msg,{icon:5,time:1000})
            }else{
                layer.msg('成功',{icon:6,time:1000},function () {
                    location.href='department_list'
                })
            }
        })
    }
</script >
</html>
